package bookstore.service.impl;


import bookstore.dao.UserDao;
import bookstore.dao.impl.UserDaoImpl;
import bookstore.entity.User;
import bookstore.service.UserService;

public class UserServiceImpl implements UserService {
    UserDao userDao = new UserDaoImpl();

    @Override  //添加用户信息 用于注册
    public int register(User user) {
        return userDao.insert(user);
    }

    @Override  //根据用户名和密码查询用户信息,登陆.
    public User login(User user) {
        return userDao.queryByUsernameAndPassword(user);
    }

    @Override  //根据用户名进行查找，查找用户名是否重复
    public boolean isExistsUsername(String username) {
        User user = userDao.queryByUsername(username);
        return user != null;
    }
}
